<?php

class Exam_Model_DbTable_Faqcategories extends Engine_Db_Table {
    protected $_rowClass = 'Exam_Model_Faqcategory';
    public function getAllFaqcategories() {
        $table=Engine_Api::_()->getDbTable('Faqcategories','Exam');
        return $table->fetchAll($table->select()->order('faqcategory_name ASC'));
    }
    public function getFaqcategoriesById($faqcategory_id) {
        $table = Engine_Api::_()->getDbTable('faqcategories', 'Exam');
        $select = $table->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
                        ->setIntegrityCheck(false);
        $select->where('faqcategory_id = ?', $faqcategory_id);
        return $table->fetchRow($select);
    }
    public function getFaqcategoriesByName($faqcategory_name) {
        $table = Engine_Api::_()->getDbTable('faqcategories', 'exam');
        $select = $table->select(Zend_Db_Table::SELECT_WITH_FROM_PART)
                ->setIntegrityCheck(false);
        $select->where('faqcategory_name = ?', $faqcategory_name);
        return $table->fetchRow($select);
    }
    
    public function addFaqcategories($faqcategory_name) {
        $table = Engine_Api::_()->getDbTable('faqcategories', 'exam');
        $data = array(
                'faqcategory_name' => $faqcategory_name,
        );
        $table->insert($data);
    }

    public function editFaqcategories($faqcategory_id, $faqcategory_name) {
        $table = Engine_Api::_()->getDbTable('faqcategories', 'exam');

        $data = array(
            'faqcategory_name' => $faqcategory_name,
        );
        $where = $table->getAdapter()->quoteInto('faqcategory_id = ?', $faqcategory_id);
        $table->update($data, $where);
    }
     public function deleteFaqcategories($faqcategory_id) {
        $table = Engine_Api::_()->getDbTable('faqcategories', 'exam');
        $where = $table->getAdapter()->quoteInto('faqcategory_id = ?', $faqcategory_id);
        $table->delete($where);
    }
     public function changeStatus($faqcategory_id, $status) {
        $table = Engine_Api::_()->getDbTable('faqcategories', 'exam');

        $data = array(
            'status' => $status,
        );
        $where = $table->getAdapter()->quoteInto('faqcategory_id = ?', $faqcategory_id);
        $table->update($data, $where);
    }
}